<template>
	<div class="caijizhan flex">
    <left2></left2>

    <div style="width: calc(100vw - 220px); height: 100vh; overflow: auto;" class="animate__animated animate__fadeIn">
      <div class="flexc" style="padding: 30px 30px 0;">
          <el-button type="primary" icon="el-icon-plus" @click="logshow">添加采集站</el-button>
      </div>
      <div class="flexc" style="padding:30px;">
        <div><el-input v-model="search.param.ip" style="width: 200px; margin-right: 20px;" placeholder="请输入采集站ip"></el-input></div>
        <div><el-input v-model="search.param.stationsNo" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 200px; margin-right: 20px;" placeholder="请输入采集站编号"></el-input></div>
        <el-button type="primary" @click="searchgo()">检索</el-button>
      </div>
      <div style="padding:0 30px;">
          <el-table :data="list" style="width: 100%;">
            <el-table-column align="center" prop="stationsId" label="采集站id"></el-table-column>
            <el-table-column align="center" prop="stationsTypeStr" label="采集站类型"></el-table-column>
            <el-table-column align="center" prop="stationsNo" label="采集站编号"></el-table-column>
            <el-table-column align="center" prop="ip" label="采集站ip"></el-table-column>
            <el-table-column align="center" prop="cjTypeStr" label="	采集方式"></el-table-column>
            <el-table-column align="center" label="操作">
              <template slot-scope="scope">
                <div class="flexcc">
                  <div style="color: #0093F6; cursor: pointer; margin: 0 10px;" @click="bianji(scope.row)">修改</div>
                  <div style="color: #f00; cursor: pointer; margin: 0 10px;" @click="shanchu(scope.row)">删除</div>
                </div>
              </template>
            </el-table-column>
          </el-table>

          <el-pagination style="padding: 20px; text-align: right;"
            @current-change="fanye"
            background
            :page-size="search.size"
            layout="total,prev, pager, next"
            :total="total">
          </el-pagination>
      </div>
    </div>

    <el-dialog :title="logtitle" center :visible.sync="log" width="1400px"  :close-on-click-modal="false" :close-on-press-escape="false" :modal-append-to-body="true">
      <el-tabs v-model="activeName2" type="card">
          <el-tab-pane label="基本信息" name="jibenxinxi">
            <div style="margin-bottom: 20px; font-weight: bold;">采集站</div>
            <div class="flexc">
              <div class="flexc" style="margin-bottom: 20px;">
                <div style="width: 100px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>采集站类型</div>
                <div>
                  <el-select v-model="all.stationsType" style="width: 300px; margin-left: 30px;"  clearable filterable placeholder="请选择采集站类型">
                      <el-option  v-for="item in xialaall.leixinglist" :key="item.value" :label="item.label" :value="parseInt(item.value)"></el-option>
                  </el-select>
                </div>
              </div>
              <div class="flexc" style="margin-bottom: 20px;">
                <div style="width: 100px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>采集站编号</div>
                <div><el-input v-model="all.stationsNo" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 300px; margin-left: 30px;" placeholder="请输入采集站编号"></el-input></div>
              </div>
              <div class="flexc" style="margin-bottom: 20px;">
                <div style="width: 100px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>采集站IP</div>
                <div><el-input v-model="all.ip" style="width: 300px; margin-left: 30px;" placeholder="请输入采集站IP"></el-input></div>
              </div>
            </div>
            <div class="flexc">
              <div class="flexc" style="margin-bottom: 20px;">
                <div style="width: 100px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>采集方式</div>
                <div>
                  <el-select v-model="all.cjType" style="width: 300px; margin-left: 30px;"  clearable filterable placeholder="请选择采集方式">
                      <el-option  v-for="item in xialaall.caijifangshilist" :key="item.value" :label="item.label" :value="parseInt(item.value)"></el-option>
                  </el-select>
                </div>
              </div>
              <div class="flexc" style="margin-bottom: 20px;">
                <div style="width: 100px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>监测设备</div>
                <div style="width: 300px; margin-left: 30px;">
                  当前已选择{{all.devIdList.length}}个设备
                  <el-button type="primary" size="small" style="margin-left: 20px;" @click="log3 = true">添加监测设备</el-button>

                  <!-- <el-select v-model="all.devIdList" style="width: 300px; margin-left: 30px;" @change="getcedian()" clearable collapse-tags filterable multiple placeholder="请选择监测设备">
                      <el-option  v-for="item in xialaall.jianceshebeilist" :key="item.value" :label="item.label" :value="item.value"></el-option>
                  </el-select> -->

                </div>
              </div>
            </div>


            <div style="margin: 20px 0; font-weight: bold;">采集通道</div>
            <el-tabs v-model="activeName" type="card">

                <el-tab-pane label="震动通道" name="first">
                  <el-table :data="all.channelDtList"  style="width: 100%" >
                    <el-table-column  label="通道号" width="80px">
                      <template slot-scope="scope">{{ scope.row.tdIndex }}</template>
                    </el-table-column>
                    <el-table-column  label="关联测点">
                      <template slot-scope="scope">
                        <el-select v-model="scope.row.dianId" clearable filterable placeholder="请选择关联测点">
                            <el-option  v-for="item in xialaall.cedianlist1" :key="item.value" :label="item.label" :value="parseInt(item.value)"></el-option>
                        </el-select>
                      </template>
                    </el-table-column>
                    <el-table-column  label="传感器类型">
                      <template slot-scope="scope">
                        <el-select v-model="scope.row.sensorType" clearable filterable placeholder="请选择传感器类型">
                            <el-option  v-for="item in xialaall.chuanganqileixinglist" :key="item.value" :label="item.label" :value="parseInt(item.value)"></el-option>
                        </el-select>
                      </template>
                    </el-table-column>
                    <el-table-column  label="灵敏系数">
                      <template slot-scope="scope">
                        <el-input v-model="scope.row.agile" placeholder="请输入灵敏系数"></el-input>
                      </template>
                    </el-table-column>
                    <el-table-column  label="是否关闭恒流源">
                      <template slot-scope="scope">
                        <el-radio v-model="scope.row.closeSource" :label="true">是</el-radio>
                        <el-radio v-model="scope.row.closeSource" :label="false">否</el-radio>
                      </template>
                    </el-table-column>
                    <el-table-column  label="停机门限值">
                      <template slot-scope="scope">
                        <el-input v-model="scope.row.stopFlag" placeholder="请输入停机门限值"></el-input>
                      </template>
                    </el-table-column>
                    <el-table-column  label="长波形采集周期倍数">
                      <template slot-scope="scope">
                        <el-select v-model="scope.row.cjCycle" clearable filterable placeholder="请选择长波形采集周期倍数">
                            <el-option  v-for="item in xialaall.zhouqibeishulist" :key="item.value" :label="item.label" :value="parseInt(item.value)"></el-option>
                        </el-select>
                      </template>
                    </el-table-column>
                    <el-table-column  label="是否启动长波形加密采集">
                      <template slot-scope="scope">
                        <el-radio v-model="scope.row.cjEncrypt" :label="true">是</el-radio>
                        <el-radio v-model="scope.row.cjEncrypt" :label="false">否</el-radio>
                      </template>
                    </el-table-column>
                  </el-table>
                </el-tab-pane>
                <el-tab-pane label="转速通道" name="second">
                  <el-table :data="all.channelZsList"  style="width: 100%" >
                    <el-table-column  label="通道号" width="80px">
                      <template slot-scope="scope">{{ scope.row.tdIndex }}</template>
                    </el-table-column>
                    <el-table-column  label="关联测点">
                      <template slot-scope="scope">
                        <el-select v-model="scope.row.dianId" clearable filterable placeholder="请选择关联测点">
                            <el-option  v-for="item in xialaall.cedianlist2" :key="item.value" :label="item.label" :value="parseInt(item.value)"></el-option>
                        </el-select>
                      </template>
                    </el-table-column>
                    <el-table-column  label="灵敏系数">
                      <template slot-scope="scope">
                        <el-input v-model="scope.row.agile" placeholder="请输入灵敏系数"></el-input>
                      </template>
                    </el-table-column>
                    <el-table-column  label="每圈脉冲数">
                      <template slot-scope="scope">
                        <el-input v-model="scope.row.pulseNum" placeholder="请输入每圈脉冲数"></el-input>
                      </template>
                    </el-table-column>
                  </el-table>
                </el-tab-pane>
                <el-tab-pane label="工艺通道" name="third">
                  <el-table :data="all.channelGyList"  style="width: 100%" >
                    <el-table-column  label="通道号" width="80px">
                      <template slot-scope="scope">{{ scope.row.tdIndex }}</template>
                    </el-table-column>
                    <el-table-column  label="关联测点">
                      <template slot-scope="scope">
                        <el-select v-model="scope.row.dianId" clearable filterable placeholder="请选择关联测点">
                            <el-option  v-for="item in xialaall.cedianlist3" :key="item.value" :label="item.label" :value="parseInt(item.value)"></el-option>
                        </el-select>
                      </template>
                    </el-table-column>
                    <el-table-column  label="输入量下限">
                      <template slot-scope="scope">
                        <el-input v-model="scope.row.inMin" placeholder="请输入输入量下限"></el-input>
                      </template>
                    </el-table-column>
                    <el-table-column  label="输入量上限">
                      <template slot-scope="scope">
                        <el-input v-model="scope.row.inMax" placeholder="请输入输入量上限"></el-input>
                      </template>
                    </el-table-column>
                    <el-table-column  label="输出量下限">
                      <template slot-scope="scope">
                        <el-input v-model="scope.row.outMin" placeholder="请输入输出量下限"></el-input>
                      </template>
                    </el-table-column>
                    <el-table-column  label="输出量上限">
                      <template slot-scope="scope">
                        <el-input v-model="scope.row.outMax" placeholder="请输出输入量上限"></el-input>
                      </template>
                    </el-table-column>
                  </el-table>
                </el-tab-pane>
                <!-- <el-tab-pane label="晃动通道" name="fourth">晃动通道</el-tab-pane> -->
              </el-tabs>
          </el-tab-pane>

          <el-tab-pane label="采集策略" name="caijicelue">
            <div class="flexc">
              <div class="flexc" style="margin-bottom: 20px;">
                <div style="width: 180px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>震动波形</div>
                <div>
                  <el-select v-model="all.cjStrategy.zdBx" style="width: 300px; margin-left: 30px;"  clearable placeholder="请选择震动波形">
                      <el-option  v-for="item in xialaall.zhendongboxinglist" :key="item.value" :label="item.label" :value="parseInt(item.value)"></el-option>
                  </el-select>
                </div>
              </div>
              <div class="flexc" style="margin-bottom: 20px;">
                <div style="width: 180px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>震动采样值</div>
                <div>
                  <el-select v-model="all.cjStrategy.zdCjy" style="width: 300px; margin-left: 30px;"  clearable filterable placeholder="请选择震动采样值">
                      <el-option  v-for="item in xialaall.zhendongcaiyangzhilist" :key="item.value" :label="item.label" :value="parseInt(item.value)"></el-option>
                  </el-select>
                </div>
              </div>
            </div>
            <div class="flexc">
              <div class="flexc" style="margin-bottom: 20px;">
                <div style="width: 180px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>晃动波形</div>
                <div>
                  <el-select v-model="all.cjStrategy.hdBx" style="width: 300px; margin-left: 30px;"  clearable filterable placeholder="请选择晃动波形">
                      <el-option  v-for="item in xialaall.huangdongboxinglist" :key="item.value" :label="item.label" :value="parseInt(item.value)"></el-option>
                  </el-select>
                </div>
              </div>
              <div class="flexc" style="margin-bottom: 20px;">
                <div style="width: 180px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>晃动采样值</div>
                <div>
                  <el-select v-model="all.cjStrategy.hdCjy" style="width: 300px; margin-left: 30px;"  clearable filterable placeholder="请选择晃动采样值">
                      <el-option  v-for="item in xialaall.huangdongcaiyangzhilist" :key="item.value" :label="item.label" :value="parseInt(item.value)"></el-option>
                  </el-select>
                </div>
              </div>
            </div>
            <div class="flexc">
              <div class="flexc" style="margin-bottom: 20px;">
                <div style="width: 180px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>测温间隔</div>
                <div><el-input v-model="all.cjStrategy.temJg" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 300px; margin-left: 30px;" placeholder="请输入过程量测温间隔"></el-input></div>
              </div>
              <div class="flexc" style="margin-bottom: 20px;">
                <div style="width: 180px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>工艺趋势采集间隔</div>
                <div><el-input v-model="all.cjStrategy.qsJg" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 300px; margin-left: 30px;" placeholder="请输入工艺趋势采集间隔"></el-input></div>
              </div>
            </div>
            <div class="flexc">
              <div class="flexc" style="margin-bottom: 20px;">
                <div style="width: 180px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>传感器检测周期</div>
                <div><el-input v-model="all.cjStrategy.sensorCycle" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 300px; margin-left: 30px;" placeholder="请输入传感器检测周期"></el-input></div>
              </div>
              <div class="flexc" style="margin-bottom: 20px;">
                <div style="width: 180px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>转速超限检测周期</div>
                <div><el-input v-model="all.cjStrategy.zsJcTime" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 300px; margin-left: 30px;" placeholder="请输入转速超限检测周期"></el-input></div>
              </div>
            </div>
            <div class="flexc">
              <div class="flexc" style="margin-bottom: 20px;">
                <div style="width: 180px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>指标门限重置间隔（小时）</div>
                <div><el-input v-model="all.cjStrategy.thresholdJg" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 300px; margin-left: 30px;" placeholder="请输入指标门限重置间隔（小时）"></el-input></div>
              </div>
              <div class="flexc" style="margin-bottom: 20px;">
                <div style="width: 180px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>指标门限更新起始数组</div>
                <div><el-input v-model="all.cjStrategy.thresholdZs" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 300px; margin-left: 30px;" placeholder="请输入指标门限更新起始数组"></el-input></div>
              </div>
            </div>
            <div style="margin-bottom: 20px; font-weight: bold;">长波形列表</div>
            <div>
              <el-button type="primary" size="small" @click="tianjialongBxList">添加长波形</el-button>

              <el-table :data="all.cjStrategy.longBxList"  style="width: 100%" >
                <el-table-column  label="波形长度">
                  <template slot-scope="scope">
                    <el-select v-model="scope.row.bxType" clearable filterable placeholder="请选择波形长度">
                        <el-option  v-for="item in xialaall.boxingchangdulist" :key="item.value" :label="item.label" :value="parseInt(item.value)"></el-option>
                    </el-select>
                  </template>
                </el-table-column>
                <el-table-column  label="加密倍数">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.encryptNum" disabled placeholder="请输入加密倍数"></el-input>
                  </template>
                </el-table-column>
                <el-table-column  label="采集间隔-低速">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.lowSpeed" disabled placeholder="请输入采集间隔-低速"></el-input>
                  </template>
                </el-table-column>
                <el-table-column  label="采集间隔-中速">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.midSpeed" disabled placeholder="请输入采集间隔-中速"></el-input>
                  </template>
                </el-table-column>
                <el-table-column  label="采集间隔-高速">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.highSpeed" disabled placeholder="请输入采集间隔-高速"></el-input>
                  </template>
                </el-table-column>
                <el-table-column  label="采集间隔-升速">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.downSpeed" disabled placeholder="请输入采集间隔-升速"></el-input>
                  </template>
                </el-table-column>
                <el-table-column  label="采集间隔-降速">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.upSpeed" disabled placeholder="请输入采集间隔-降速"></el-input>
                  </template>
                </el-table-column>
                <el-table-column  label="操作">
                  <template slot-scope="scope">
                    <el-button type="danger" size="mini" @click="shanchulongBxList(scope.$index)">删除</el-button>
                    <el-button type="danger" size="mini" @click="xiugailongBxList(scope.row,scope.$index)">修改</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
      </el-tabs>




    	  <span slot="footer" class="dialog-footer">
          <el-button type="danger" round @click="log = false">取消</el-button>
          <el-button type="danger" round @click="add">确定</el-button>
    	  </span>
    </el-dialog>
    <el-dialog :title="changboxingtitle" center :visible.sync="log2" width="400px"  :close-on-click-modal="false" :close-on-press-escape="false" :modal-append-to-body="true">
      <div style="margin-bottom: 20px;">
        <el-select v-model="changboxingall.bxType" style="width: 100%;" clearable filterable placeholder="请选择波形长度">
            <el-option  v-for="item in xialaall.boxingchangdulist" :key="item.value" :label="item.label" :value="parseInt(item.value)"></el-option>
        </el-select>
      </div>
      <div style="margin-bottom: 20px;">
        <el-input v-model="changboxingall.encryptNum" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" placeholder="请输入加密倍数"></el-input>
      </div>

      <div style="font-weight: bold; margin-bottom: 20px;">采集间隔（小时）</div>
      <div style="margin-bottom: 20px;">
        <el-input v-model="changboxingall.lowSpeed" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" placeholder="请输入采集间隔-低速"></el-input>
      </div>
      <div style="margin-bottom: 20px;">
        <el-input v-model="changboxingall.midSpeed" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" placeholder="请输入采集间隔-中速"></el-input>
      </div>
      <div style="margin-bottom: 20px;">
        <el-input v-model="changboxingall.highSpeed" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" placeholder="请输入采集间隔-高速"></el-input>
      </div>
      <div style="margin-bottom: 20px;">
        <el-input v-model="changboxingall.downSpeed" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" placeholder="请输入采集间隔-升速"></el-input>
      </div>
      <div style="margin-bottom: 20px;">
        <el-input v-model="changboxingall.upSpeed" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" placeholder="请输入采集间隔-降速"></el-input>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="danger" round @click="log2 = false">取消</el-button>
        <el-button type="danger" round @click="changboxinggo">确定</el-button>
      </span>
    </el-dialog>

    <el-dialog title="选择监测设备" center :visible.sync="log3" width="900px"  :close-on-click-modal="false" :close-on-press-escape="false" :modal-append-to-body="true">
      <!-- <el-select v-model="all.devIdList" style="width: 300px; margin-left: 30px;" @change="getcedian()" clearable collapse-tags filterable multiple placeholder="请选择监测设备">
          <el-option  v-for="item in xialaall.jianceshebeilist" :key="item.value" :label="item.label" :value="item.value"></el-option>
      </el-select> -->
      <el-checkbox-group v-model="all.devIdList" @change="changes">
          <el-checkbox v-for="item in xialaall.jianceshebeilist" :key="item.value" :disabled="all.devIdList.includes(item.value)" :label="item.value" style="width: 250px; margin-bottom: 20px;">{{item.label}}</el-checkbox>
      </el-checkbox-group>

      <!-- <span slot="footer" class="dialog-footer">
        <el-button type="danger" round @click="log3 = false">取消</el-button>
        <el-button type="danger" round @click="xuanzeshebeiqueding">确定</el-button>
      </span> -->
    </el-dialog>
	</div>
</template>

<script>

  import { addstations,removestations,updatestations,getstations,getevall,getdianall,getstationsall } from '@/api/caijizhan.js'
  import { postxiala } from '@/api/shuju'
  import left2 from '@/view/left2.vue'
	export default {
		name: 'caijizhan',
    components:{
      left2
    },
		data() {
			return {
        activeName2:'jibenxinxi',
        activeName:'first',
        all:{
          "stationsType":"",//采集站类型
          "stationsNo":"",//采集站编号
          "ip":"",//采集站ip192.168.1.111
          "cjType":"",//采集方式 字典
          "devIdList":[],//监测设备 取设备列表
          "cjStrategy":{ //采集策略
            "zdBx":"",
            "zdCjy":"",
            "hdBx":"",
            "hdCjy":"",
            "temJg":"",
            "qsJg":"",
            "sensorCycle":"",
            "zsJcTime":"",
            "thresholdJg":"",
            "thresholdZs":"",
            "longBxList":[],
          },
          //长波形列表
          "channelDtList":[ ],
          //转速通道列表
          "channelZsList":[ ],
           //工艺通道列表
          "channelGyList":[]
        },
        list:[],
        search:{
            "page":1,
            "size":10,
            "param":{
              "ip":"",
              "stationsNo":""
            }
        },
        total:0,

        log:false,
        log2:false,
        log3:false,
        logtitle:"",

        xialaall:{},

        changboxingall:{},
        changboxingindex:"",
        changboxingtitle:'新增长波形'
			}
		},
		created() {
      this.getlist()
      this.getxialalist()
		},
		mounted() {

		},
		methods: {
      changes:function(){
        this.getcedian()
        console.log(this.all.devIdList)
      },
      xuanzeshebeiqueding:function(){
        this.getcedian()
        this.log3 = false
      },
      xiugailongBxList:function(item,index){
        this.changboxingindex = index
        this.changboxingtitle = '修改长波形'
        this.changboxingall = {
          "bxType":item.bxType,
          "encryptNum":item.bxType,
          "lowSpeed":item.bxType,
          "midSpeed":item.bxType,
          "highSpeed":item.bxType,
          "downSpeed":item.bxType,
          "upSpeed":item.bxType,
        }
        this.log2 = true
      },
      changboxinggo:function(){
        if(this.changboxingtitle == '修改长波形'){
          this.$set(this.all.cjStrategy.longBxList,this.changboxingindex,this.changboxingall)

        }else{
          this.all.cjStrategy.longBxList.push(this.changboxingall)
        }

        this.log2 = false
      },
      tianjialongBxList:function(){
        this.changboxingtitle = '新增长波形'
        let bxType
        this.xialaall.boxingchangdulist.forEach(item=>{
          if(item.mr){bxType = parseInt(item.value) }
        })

        this.changboxingall = {
          "bxType":bxType,
          "encryptNum":"",
          "lowSpeed":"",
          "midSpeed":"",
          "highSpeed":"",
          "downSpeed":"",
          "upSpeed":"",
        }
        this.log2 = true
        // this.all.cjStrategy.longBxList.push(obj)
      },
      shanchulongBxList:function(index){
        this.all.cjStrategy.longBxList.splice(index,1)
      },
      getcedian:function(){
        let str = ""
        if(this.all.devIdList){
          str = this.all.devIdList.toString()
        }
        return new Promise((res,rej)=>{
          getdianall(str,21).then((response)=>{
            this.$set(this.xialaall,'cedianlist1',response.data)
            res()
          })
          getdianall(str,22).then((response)=>{
            this.$set(this.xialaall,'cedianlist2',response.data)
            res()
          })
          getdianall(str,23).then((response)=>{
            this.$set(this.xialaall,'cedianlist3',response.data)
            res()
          })
        })
      },
      qinghuancun:function(){
        refreshtype().then((response)=>{
          this.$message.success('清除缓存成功');
          this.getlist()
        })
      },
      guanli:function(item){
        this.$router.push({
          path:'/zidian/zidianshuju',
          query:{
            allDictType:item.allDictType,
          }
        })
      },

      shanchu:function(item){
        this.$confirm('此操作将永久删除, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          removestations(item.stationsId).then((response)=>{
            this.$message.success('删除成功');
            this.getlist()
          })
        })
      },

      bianji:function(item){
        this.logtitle = '修改采集器'
        getstations(item.stationsId).then((response)=>{
          this.all = response.data
          //获取一下设备关联的测点
          this.getcedian().then(()=>{
            this.log = true
          })
        })

      },
      //新增初始化
      chushihua:function(){
        this.$set(this.xialaall,'cedianlist',[])
        this.all = {
          "stationsType":"",//采集站类型
          "stationsNo":"",//采集站编号
          "ip":"",//采集站ip192.168.1.111
          "cjType":"",//采集方式 字典
          "devIdList":[],//监测设备 取设备列表
          "cjStrategy":{ //采集策略
            "zdBx":"",
            "zdCjy":"",
            "hdBx":"",
            "hdCjy":"",
            "temJg":"",
            "qsJg":"",
            "sensorCycle":"",
            "zsJcTime":"",
            "thresholdJg":"",
            "thresholdZs":"",
            "longBxList":[],
          },
          //长波形列表
          "channelDtList":[ ],
          //转速通道列表
          "channelZsList":[ ],
           //工艺通道列表
          "channelGyList":[]
        }
        let sensorType,cjCycle
        this.xialaall.chuanganqileixinglist.forEach(item=>{
          if(item.mr){sensorType = parseInt(item.value) }
        })
        this.xialaall.zhouqibeishulist.forEach(item=>{
          if(item.mr){cjCycle = parseInt(item.value) }
        })

        for (var i = 0; i < 16; i++) {
          let obj = {
            "tdIndex":i+1,
            "dianId":"",
            "sensorType":sensorType,
            "agile":"",
            "closeSource":false,
            "stopFlag":"",
            "cjCycle":cjCycle,
            "cjEncrypt":false,
          }
          this.all.channelDtList.push(obj)
          let obj2 = {
            "tdIndex":i+1,
            "dianId":"",
            "agile":"",
            "pulseNum":"",
          }
          if(i<2){
            this.all.channelZsList.push(obj2)
          }
          let obj3 = {
            "tdIndex":i+1,
            "dianId":"",
            "inMin":"",
            "inMax":"",
            "outMin":"",
            "outMax":"",
          }
          if(i<4){
            this.all.channelGyList.push(obj3)
          }
          this.xialaall.leixinglist.forEach(item=>{
            if(item.mr){this.all.stationsType = parseInt(item.value) }
          })
          this.xialaall.caijifangshilist.forEach(item=>{
            if(item.mr){this.all.cjType = parseInt(item.value) }
          })
          this.xialaall.zhendongboxinglist.forEach(item=>{
            if(item.mr){this.all.cjStrategy.cjType = parseInt(item.value) }
          })
          this.xialaall.zhendongcaiyangzhilist.forEach(item=>{
            if(item.mr){this.all.cjStrategy.zdCjy = parseInt(item.value) }
          })
          this.xialaall.huangdongboxinglist.forEach(item=>{
            if(item.mr){this.all.cjStrategy.hdBx = parseInt(item.value) }
          })
          this.xialaall.huangdongcaiyangzhilist.forEach(item=>{
            if(item.mr){this.all.cjStrategy.hdCjy = parseInt(item.value) }
          })


        }
      },
      logshow:function(){
        this.logtitle = '新增采集站'
        this.chushihua()
        this.log = true
      },

      add:function(){
        if(this.all.stationsId){
          updatestations(this.all).then((response)=>{
            this.$message.success('修改成功');
            this.log = false
            this.getlist()
          })
        }else{
          addstations(this.all).then((response)=>{
            this.$message.success('新增成功');
            this.log = false
            this.getlist()
          })
        }
      },

      searchgo:function(){
        this.search.page = 1
        this.getlist()
      },

      getlist:function(){
        getstationsall(this.search).then((response)=>{
          this.list = response.data.result
          this.total = response.data.count
        })
      },

      fanye:function(val){
        this.search.page = val
        this.getlist()
      },


      //获取下啦数据用
      getxialalist:function(){
        getevall(this.search).then((response)=>{
          this.xialaall.jianceshebeilist = response.data
        })
        let obj = {
          sysName:"采集站",
          dictName:"采集站-类型",
          dictType:""
        }
        postxiala(obj).then(response => {
          this.xialaall.leixinglist = response.data
        })
        let obj2 = {
          sysName:"采集站",
          dictName:"采集站-采集方式",
          dictType:""
        }
        postxiala(obj2).then(response => {
          this.xialaall.caijifangshilist = response.data
        })
        let obj3 = {
          sysName:"采集站",
          dictName:"振动通道-传感器类型",
          dictType:""
        }
        postxiala(obj3).then(response => {
          this.xialaall.chuanganqileixinglist = response.data
        })
        let obj4 = {
          sysName:"采集站",
          dictName:"振动通道-长波形采集周期倍数",
          dictType:""
        }
        postxiala(obj4).then(response => {
          this.xialaall.zhouqibeishulist = response.data
        })
        let obj5 = {
          sysName:"采集站",
          dictName:"采集策略-振动波形",
          dictType:""
        }
        postxiala(obj5).then(response => {
          this.xialaall.zhendongboxinglist = response.data
        })
        let obj6 = {
          sysName:"采集站",
          dictName:"采集策略-振动采样值",
          dictType:""
        }
        postxiala(obj6).then(response => {
          this.xialaall.zhendongcaiyangzhilist = response.data
        })
        let obj7 = {
          sysName:"采集站",
          dictName:"采集策略-晃动波形",
          dictType:""
        }
        postxiala(obj7).then(response => {
          this.xialaall.huangdongboxinglist = response.data
        })
        let obj8 = {
          sysName:"采集站",
          dictName:"采集策略-晃动采样值",
          dictType:""
        }
        postxiala(obj8).then(response => {
          this.xialaall.huangdongcaiyangzhilist = response.data
        })
        let obj9 = {
          sysName:"采集站",
          dictName:"采集策略-波形长度",
          dictType:""
        }
        postxiala(obj9).then(response => {
          this.xialaall.boxingchangdulist = response.data
        })
        let obj10 = {
          sysName:"采集站",
          dictName:"参数设置-波形门限",
          dictType:""
        }
        postxiala(obj10).then(response => {
          this.xialaall.boxingmenxianlist = response.data
        })
        let obj11 = {
          sysName:"采集站",
          dictName:"参数设置-计算长度",
          dictType:""
        }
        postxiala(obj11).then(response => {
          this.xialaall.jisuanchangdulist = response.data
        })
      }
		}
	}
</script>


<style scoped >

</style>
